<template>
    销售开发
    <el-form :model="sellForm" label-width="auto" style="max-width: 600px">
        <el-form-item label="客户名称">
            <el-select v-model="sellForm.custId" class="m-2" placeholder="。。。">
                <el-option :label="cust.custName" :value="cust.id" v-for="cust in custList"/>
            </el-select>
        </el-form-item>
        <el-form-item label="销售渠道">
            <el-select v-model="sellForm.channelId" placeholder="please select your type">
                <el-option label="自媒体" value="0" />
                <el-option label="网络推广" value="1" />
                <el-option label="老客户简介" value="2" />
                <el-option label="陌拜" value="3" />
                <el-option label="测试" value="4" />
                <el-option label="测试" value="5" />
            </el-select>
        </el-form-item>
        <el-form-item label="销售金额">
            <el-input v-model="sellForm.money" />
        </el-form-item>
        <el-form-item label="开发阶段">
            <el-select v-model="sellForm.nowStep" placeholder="请选择...">
                <el-option label="解除" value="T1" />
                <el-option label="测试1" value="T2" />
                <el-option label="测试2" value="T3" />
                <el-option label="测试3" value="T4" />
                <el-option label="测试4" value="T5" />
            </el-select>
        </el-form-item>
        <el-form-item label="Grade">
            <el-input v-model.number="sellForm.empId" type="text" autocomplete="off" />
        </el-form-item>

        <el-form-item>
            <el-button type="primary" @click="onSubmit">保存</el-button>
            <el-button>Cancel</el-button>
        </el-form-item>
    </el-form>
</template>

<script setup>
import axios from 'axios';
import { onMounted, reactive, ref } from 'vue';
import { ElMessage } from 'element-plus'

const sellForm = reactive({
    custId: 0,
    channelId: 0,
    money: 0,
    nowStep: '',
    empId: 0
})

const custList = ref([])

function getAllCust() {
    axios.get("http://localhost:8081/listAllCust").then((resp)=>{
        if(resp.data.code == 200) {
            custList.value = resp.data.data
        } else {

        }
    }).catch((error)=>{
        console.log(error)
    })
}

function onSubmit() {
    axios.post("http://localhost:8081/addSell", sellForm).then((resp)=>{
        console.log(resp.data)
        ElMessage({
            message: '提交成功!',
            type: 'success',
        })
    })
}

onMounted(()=>{
    getAllCust()
})
</script>

<style scoped></style>